package com.wzx.studyspringboot.controller;

import com.wzx.studyspringboot.dao.ProductDao;
import com.wzx.studyspringboot.domain.Product;
import com.wzx.studyspringboot.mapper.ProductMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName MybatisController
 * @Description TODO
 * @Author wuzhixuan
 * @Date 2018/12/28 17:53
 * @Version 1.0
 */
@RestController
public class MybatisController {
    @Autowired
    ProductDao productDao;

    @Autowired
    ProductMapper productMapper;
    @RequestMapping("findProduct")
    public Product findProduct(){
        return productMapper.findProductById(100L);
    }

    @RequestMapping("saveProduct")
    public void saveProduct(){
        Product product =new Product();
        product.setName("吴志旋");
        product.setCategory("人");
        productDao.saveProduct(product);
    }

    @RequestMapping("deleteProduct")
    public void deleteProduct(){
         productDao.deleteProduct(100l);
    }
}
